package coroutines.coroutine.coroutinescope

import kotlinx.coroutines.*

class coroutineScopeTest {
}

fun main() {
    val scope = CoroutineScope(Job())
    scope.cancel()

    runBlocking(context = Dispatchers.IO) {
        coroutineScope {
            println("coroutineScope start0")

            launch {
                println("launch1 start thread = ${Thread.currentThread().name}, coroutineScope.isActive = ${this@coroutineScope.isActive}")
                delay(100)
                println("launch1 end thread = ${Thread.currentThread().name}, coroutineScope.isActive = ${this@coroutineScope.isActive}")
            }

            launch {
                println("launch2 start thread = ${Thread.currentThread().name}, coroutineScope.isActive = ${this@coroutineScope.isActive}")
                delay(200)
                println("launch2 end thread = ${Thread.currentThread().name}, coroutineScope.isActive = ${this@coroutineScope.isActive}")
            }

            launch {
                println("launch3 start thread = ${Thread.currentThread().name}, coroutineScope.isActive = ${this@coroutineScope.isActive}")
                delay(300)
                println("launch3 end thread = ${Thread.currentThread().name}, coroutineScope.isActive = ${this@coroutineScope.isActive}")
            }

            println("coroutineScope start1")
        }
    }
}